# Make a movie of an nBody simulation

import matplotlib as mpl
import numpy as np
import matplotlib.pyplot as plt
import os
import sys
import plotter
import gc

def makeMovie():
   for i in range (2000):
      gc.collect()
      plotter.plotData("../data/DD"+str(i).zfill(4))


makeMovie()

# Link the frames into an image.
command = ('mencoder',
      'mf://../plots/*.png',
      '-mf',
      'type=png:w=800:h=600:fps=25',
      '-ovc',
      'lavc',
      '-lavcopts',
      'vcodec=mpeg4',
     '-oac',
      'copy',
      '-o',
      'output.avi')

os.spawnvp(os.P_WAIT, 'mencoder', command)

#os.system("rm *.png")
